﻿using EPE.BLL;
using EPE.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace EPE.WPF
{
    /// <summary>
    /// UCUserList.xaml 的交互逻辑
    /// </summary>
    public partial class UCUserList : UserControl
    {
        public UCUserList()
        {
            InitializeComponent();

            BindData();
        }

        CLoginUser userinfo = new CLoginUser();
        public UCUserList(CLoginUser pargUserinfo)
        {
            InitializeComponent();
            userinfo = pargUserinfo;
            
        }

        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            BindData();
        }

        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            UserAdd vca = new UserAdd();
            vca.ShowDialog();
        }

        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {

        }

        private void btnDel_Click(object sender, RoutedEventArgs e)
        {

        }

        public void BindData()
        {


            DataSet ds = new DataSet();



            UserMgr bll = new UserMgr();


            ds = bll.GetListByPage(this.txtName.Text, "account",this.pagectrl.PageIndex,this.pagectrl.PageSize);

            DataTable dt = ds.Tables[0];
            
            this.dgList.DataContext = dt;
            this.pagectrl.TotalCount = Convert.ToInt32(ds.Tables[1].Rows[0][0]);
        }

        private void pagectrl_PagerIndexChanged(object sender, EventArgs e)
        {
            BindData();
        }

       

    }
}
